package com.game.gameshoppingcenter.service;

import com.game.gameshoppingcenter.dao.UsersRepository;

import com.game.gameshoppingcenter.entities.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Service
public class UsersService {
    @Autowired
    UsersRepository userRepository;


    public List<Users> getAll() {
        return userRepository.findAll();

    }

    public Users save(Users users) {
        return userRepository.save(users);
    }

    public boolean getfindByNameAndPassword(HttpServletRequest request) {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println(username);
        System.out.println(password);
        List<Users> users = userRepository.findByNameAndPassword(username, password);
        System.out.println(users);
        if(users.size()!=0){
            return true;
        }else {
            return false;
        }
    }
}
